package cn.pfz.Service.impl;

import cn.pfz.Service.ISystemDictionaryItemSerives;
import cn.pfz.domain.SystemDictionary;
import cn.pfz.domain.SystemDictionaryItem;
import cn.pfz.mapper.SystemDictionaryItemMapper;
import cn.pfz.query.SystemDictionaryItemQueryObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ISystemDictionaryItemSerivesimpl implements ISystemDictionaryItemSerives {
    @Autowired
    private SystemDictionaryItemMapper systemDictionaryItemMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return systemDictionaryItemMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SystemDictionaryItem record) {
        return systemDictionaryItemMapper.insert(record);
    }

    @Override
    public SystemDictionaryItem selectByPrimaryKey(Long id) {
        return systemDictionaryItemMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SystemDictionaryItem> selectAll() {
        return systemDictionaryItemMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(SystemDictionaryItem record) {
        return systemDictionaryItemMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<SystemDictionaryItem> list(SystemDictionaryItemQueryObject qo) {
        //通过pageHelper进行设置分页及排序
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),"id asc");
        //在Sql中不需要limit
        List<SystemDictionaryItem> list = systemDictionaryItemMapper.selectForList(qo);
        PageInfo<SystemDictionaryItem> PageInfo = new PageInfo(list);
        return PageInfo;
    }

    @Override
    public List<SystemDictionary> selectParent() {
        return systemDictionaryItemMapper.selectParent();
    }

    @Override
    public List<SystemDictionaryItem> selectByTpyeid(int i) {
        return systemDictionaryItemMapper.selectByTpyeid(i);
    }
}
